The present examples relate to a computer device, and more particularly, to managing memory for graphics processing on a computer device.
Computer graphics systems, which can render 2D objects or objects from a 3D world (real or imaginary) onto a two-dimensional (2D) display screen, are currently used in a wide variety of applications. For example, 3D computer graphics can be used for real-time interactive applications, such as video games, virtual reality, scientific research, etc., as well as off-line applications, such as the creation of high resolution movies, graphic art, etc. Typically, the graphics system includes a graphics processing unit (GPU). A GPU may be implemented as a co-processor component to a central processing unit (CPU) of the computer, and may be provided in the form of an add-in card (e.g., video card), co-processor, or as functionality that is integrated directly into the motherboard of the computer or into other devices, such as a gaming device.
Typically, the GPU has a “logical graphics pipeline,” which may accept as input some representation of a 2D or 3D scene and output a bitmap that defines a 2D image for display. For example, the DirectX collection of application programming interfaces by MICROSOFT CORPORATION, including the DIRECT3D application programming interface (API), is an example of APIs that have graphic pipeline models. Another example includes the Open Graphics Library (OPENGL) API. The graphics pipeline typically includes a number of stages to convert a group of vertices, textures, buffers, and state information into an image frame on the screen. For instance, one of the stages of the graphics pipeline is a shader. A shader is a piece of code running on a specialized processing unit, also referred to as a shader unit or shader processor, usually executing multiple data threads at once, programmed to generate appropriate levels of color and/or special effects to fragments being rendered. In particular, for example, a vertex shader processes traits (position, texture coordinates, color, etc.) of a vertex, and a pixel shader processes traits (texture values, color, z-depth and alpha value) of a pixel. GPUs now also execute compute shaders that can perform highly-parallelized general-purpose computations that may or may not relate to graphics processing.
Memory resources can be allocated for GPUs (e.g., via driver or title executing on a central processing unit (CPU) that manages the memory resources) for performing various graphics processing operations, such as operating shaders or other stages in the graphics pipeline. The driver typically allocates a large amount of memory sufficient for performing the operations. In some cases, however, an amount of memory that is used by a shader or other resource may not be known at the outset of processing, and launching of multiple shaders using the large amount of memory may be prohibitive or wasteful of available system resources.